package com.tree.commonresultdemo.result;

/**
 * @author zhong
 * @version 1
 * @date 2022/04/10
 * @contact 1478168700@qq.com
 **/
public class ResultUtil {

    private ResultUtil() {

    }

    public static <T> Result<T> defineSuccess(int code, T data) {
        return ResultBuilder.aResult().withCode(code).withData(data).build();
    }

    public static <T> Result<T> success(T data) {
        return ResultBuilder.aResult().withCode(ResultEnum.SUCCESS.getCode()).withData(data).build();

    }

    public static <T> Result<T> fail(String msg) {
        return ResultBuilder.aResult().withCode(ResultEnum.FAIL.getCode()).withMsg(msg).build();
    }

    public static <T> Result<T> defineFail(int code, String msg) {
        return ResultBuilder.aResult().withCode(code).withMsg(msg).build();

    }

    public static <T> Result<T> define(int code, String msg, T data) {
        return ResultBuilder.aResult().withCode(code).withMsg(msg).withData(data).build();
    }

}
